const QQMapWX = require('../libs/qqmap-wx-jssdk1.2/qqmap-wx-jssdk')
var qqmapsdk;

module.exports = {


addressAnalysis(address, index, item) {
    const that = this

    qqmapsdk.geocoder({
        //获取表单传入地址
        address: address, //地址
        success: function (res) {//成功后的回调
            // resolve(res.result.location)
            console.log(index, "内")
            console.log(that.data.paramArr)
            // console.log(address, "内")
            // console.log(res.result.location, "内")
            // console.log(item, "内")
            //   this.data.paramArr()
            that.data.paramArr.push({
                storeId: that.data.storeId,
                shipId: item.id,
                xpoint: res.result.location.lng,
                ypoint: res.result.location.lat
            })
            console.log(that.data.paramArr, "kkkkkkkkkkkkkk")
            console.log(that.data.addressLists, "kkkkkkkkkkkkkk")
            if(that.data.paramArr.length==that.data.addressLists.length){
                console.log(that.data.paramArr, "kkkkkkkkkkkkkk")
                that.getIsList(that.data.paramArr)  //是否可以配送  
            }
            
        },
        fail: function (error) {
            common.showToast(error)
        },
        complete: function (res) {
            
        }
    })
   
},

  // 170济南 171青岛 172淄博 173枣庄 174东营 175烟台 176潍坊 177济宁
  // 178泰安 179威海 180日照 182临沂 183德州 184聊城 185滨州 186菏泽
  cityMap: {
    '170': '济南', '171': '青岛', '172': '淄博', '173': '枣庄',
    '174': '东营', '175': '烟台', '176': '潍坊', '177': '济宁',
    '178': '泰安', '179': '威海', '180': '日照', '182': '临沂',
    '183': '德州', '184': '聊城', '185': '滨州', '186': '菏泽',
    '16': '山东省'
  },
  regionMap: {
    '1849': '莱山', '1858': '烟台开发区', '1893': '环翠区', '1851': '龙口'
  },
  /**
 * 获取专题页的标题
 * @param {string} cityId 城市标识
 * @param {string} regionId 区县标识， 默认为空字符串
 */
// 音频播放只能在这几个页面播放
isUrl(url){


   if(url=='pages/ScenicArea/ScenicAreaMainPage/index' ||
   url=='pages/ScenicArea/ScenicAreaGoodsList/index'  ||
   url=='pages/ScenicArea/discovery/index'  ||
   url=='pages/ScenicArea/ScenicAreaComment/index' ||
   url=='pages/ScenicArea/ScenicAreaOrder/index' 
   
   ){

    return true
   }else{
     return false
   }

},

  getTopicTitle(cityId, regionId = '') {
    const regionName = regionId != '' ? this.regionMap[regionId] : null
    let cityName = regionName ? regionName : (cityId ? this.cityMap[cityId] : null)
    cityName = cityName ? cityName : ''
    return cityName
  },
  // 封装方法
  
  /**
   * 领券专题页是否包含某个地区
   * @param {string} id 地区标识
   */
  containRegion(id) {
    return this.getTopicTitle(null, id) !== ''
  }
}